package ar.edu.unq.ts.components.abstracts;

import java.awt.geom.Point2D.Double;

import ar.edu.unq.ts.extra.Direccion;

import com.uqbar.vainilla.DeltaState;

public abstract class SightObserver extends CenterableComponent {
	
	private Direccion direccion;

	public SightObserver(double x, double y) {
		super(x, y);
		this.setDireccion(Direccion.SUR);
	}
	
	public abstract void setSightAngle(double radianes);
	
	@Override
	public void update(DeltaState deltaState) {
		super.update(deltaState);
	    this.setPosition(deltaState.getCurrentMousePosition());
	}

	private void setPosition(Double currentMousePosition) {
		
		double xVector = currentMousePosition.getX() - this.absCenterX();
		double yVector = currentMousePosition.getY() - this.absCenterY();
		double angle = 0.0;
		if(xVector == 0.0){
			if(yVector < 0){
				this.direccion = Direccion.NORTE;
			}
			else{
				this.direccion = Direccion.SUR;
			}
		}
		else {
			angle = StrictMath.atan(yVector / xVector);
		}
		this.getScene().prompt(this.direccion.getName() + " - " + angle);
	}

	public Direccion getDireccion() {
		return direccion;
	}
	
	public void setDireccion(Direccion direccion) {
		this.direccion = direccion;
	}
	

	
}
